Ubuntu 24.04 Power-Off Prevention Documentation

This documentation describes the step-by-step process to prevent Ubuntu 24.04 from automatically powering off when idle on AC power.

Step 1: Verify AC idle action

gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
# Output: 'nothing'

Step 2: Verify battery idle action

gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type
# Output: 'nothing'

Step 3: Check systemd sleep target status

sudo systemctl status sleep.target
# Output:
# ○ sleep.target - Sleep
#      Loaded: loaded (/usr/lib/systemd/system/sleep.target; static)
#      Active: inactive (dead)
#        Docs: man:systemd.special(7)

Step 4: Verify logind configuration for power and idle actions

sudo grep -E "Handle|Idle" /etc/systemd/logind.conf
# Output:
# #HandlePowerKey=poweroff
# #HandlePowerKeyLongPress=ignore
# #HandleRebootKey=reboot
# #HandleRebootKeyLongPress=poweroff
# #HandleSuspendKey=suspend
# #HandleSuspendKeyLongPress=hibernate
# #HandleHibernateKey=hibernate
# #HandleHibernateKeyLongPress=ignore
# #HandleLidSwitch=suspend
# #HandleLidSwitchExternalPower=suspend
# #HandleLidSwitchDocked=ignore
# #IdleAction=ignore
# #IdleActionSec=30min
# #StopIdleSessionSec=infinity

Step 5: Check scheduled timers for shutdown

systemctl list-timers --all | grep -i shutdown
# Output: (no output)

Step 6: Verify suspend services

systemctl list-unit-files | grep -i suspend
# Output:
# nvidia-suspend.service                                                        enabled         enabled
# systemd-suspend-then-hibernate.service                                        static          -
# systemd-suspend.service                                                       static          -
# suspend-then-hibernate.target                                                 static          -
# suspend.target                                                                static          -

Step 7: Check AC idle timeout value

gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout
# Output: 900

Step 8: Disable AC idle timeout

gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0

Step 9: Restart GNOME power plugin to apply changes

killall -HUP gnome-settings-daemon

After these steps, Ubuntu 24.04 should no longer automatically power off when idle on AC power.

slimani@slimani-Latitude-E5570:~$ gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type
'nothing'
slimani@slimani-Latitude-E5570:~$ gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type
'nothing'
slimani@slimani-Latitude-E5570:~$ sudo systemctl status sleep.target
○ sleep.target - Sleep
     Loaded: loaded (/usr/lib/systemd/system/sleep.target; static)
     Active: inactive (dead)
       Docs: man:systemd.special(7)
slimani@slimani-Latitude-E5570:~$ sudo grep -E "Handle|Idle" /etc/systemd/logind.conf
#HandlePowerKey=poweroff
#HandlePowerKeyLongPress=ignore
#HandleRebootKey=reboot
#HandleRebootKeyLongPress=poweroff
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#IdleAction=ignore
#IdleActionSec=30min
#StopIdleSessionSec=infinity
slimani@slimani-Latitude-E5570:~$ systemctl list-timers --all | grep -i shutdown
slimani@slimani-Latitude-E5570:~$ systemctl list-unit-files | grep -i suspend
nvidia-suspend.service                                                        enabled         enabled
systemd-suspend-then-hibernate.service                                        static          -
systemd-suspend.service                                                       static          -
suspend-then-hibernate.target                                                 static          -
suspend.target                                                                static          -
slimani@slimani-Latitude-E5570:~$ gsettings get org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout
900
slimani@slimani-Latitude-E5570:~$ gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
slimani@slimani-Latitude-E5570:~$ killall -HUP gnome-settings-daemon
gnome-settings-daemon: no process found
slimani@slimani-Latitude-E5570:~$ systemctl --user restart gnome-session.target
Failed to restart gnome-session.target: Operation refused, unit gnome-session.target may be requested by dependency only (it is configured to refuse manual start/stop).
See user logs and 'systemctl --user status gnome-session.target' for details.
slimani@slimani-Latitude-E5570:~$